Authenticate User using Tokens

{ authenticateUserByToken }

Generates an access authentication token for a given user without their password, using an administrative token to authorize login to the application instead.

Method

/API3/authentication/authenticateUserByToken

  • API Section: /API3/authentication
  • API Version: 3.0
  • From Release: 2023.10
  • Usage: REST API and Client SDK libraries. REST APIs via POST actions only.
  • Usage by:
    • Enterprise Admin
    • Domain Admin
  • Input Parameters

    Name

    userTokenCredentials

    Object Type

    Description

    The user credentials for authentication by token.

    Output Response

    Successful Result Code

    200

    Response Type

    string

    Description of Response Type

    The response is the security token as a base64 string. It is usually stored in a cookie.

    Notes

    The security token is an authentication token that needs to be first generated by an administrative user with full credentials first.When saved as a cookie in a web browser, it can then be used to auto-login the user into the application.

    Examples

    Code Snippets

    TypeScript
    Curl
    Java
    C#
    Python
    PHP
    curl -X POST \
     -H "Accept: text/plain,text/plain;charset=utf-8" \
     -H "Content-Type: application/json" \
     "http://Your.Server.URL/API3/authentication/authenticateUserByToken" \
     -d '{
      "domain" : "domain",
      "customData" : "customData",
      "userIdentity" : "userIdentity",
      "token" : "token"
    }'
    
    import com.pyramidanalytics.*;
    import com.pyramidanalytics.auth.*;
    import com.pyramidanalytics.model.*;
    import com.pyramidanalytics.api.AuthenticationServiceApi;
    
    import java.util.*;
    import java.time.*;
    
    public class AuthenticationServiceApiExample {
        public static void main(String[] args) {
            ApiClient defaultClient = Configuration.getDefaultApiClient();
            defaultClient.setBasePath("http://Your.Server.URL/");
    
            // Create an instance of the API class
            AuthenticationServiceApi apiInstance = new AuthenticationServiceApi();
            // Initialize the userTokenCredentials parameter object for the call
            UserTokenCredentials userTokenCredentials = ; // Create the input object for the operation, type: UserTokenCredentials 
    
            try {
                String result = apiInstance.authenticateUserByToken(userTokenCredentials);
                System.out.println(result);
            } catch (ApiException e) {
                System.err.println("Exception when calling AuthenticationServiceApi#authenticateUserByToken");
                e.printStackTrace();
            }
        }
    }
    
    import * as PyramidAnalyticsWebApi from "com.pyramidanalytics";
    
    // Create an instance of the API class
    const api = new PyramidAnalyticsWebApi.AuthenticationServiceApi("http://Your.Server.URL")
    
    const userTokenCredentials = ; // {UserTokenCredentials} 
    
    api.authenticateUserByToken(userTokenCredentials).then(function(data) {
      console.log('API called successfully. Returned data: ' + data);
    }, function(error) {
      console.error(error);
    });
    
    
    using System;
    using System.Diagnostics;
    using PyramidAnalytics.Sdk.Api;
    using PyramidAnalytics.Sdk.Client;
    using PyramidAnalytics.Sdk.Model;
    
    public class authenticateUserByTokenExample
    {
        public static void Main()
        {
            Configuration conf = new Configuration();
            conf.BasePath = "http://Your.Server.URL/";
            
            
            GlobalConfiguration.Instance = conf;
            
            // Create an instance of the API class
            var apiInstance = new AuthenticationServiceApi();
            // Initialize the userTokenCredentials parameter object for the call
            var userTokenCredentials = new UserTokenCredentials(); // UserTokenCredentials | 
    
            try {
                // Generates an access authentication token for a given user without their password, using an administrative token to authorize login to the application instead.
                string result = apiInstance.authenticateUserByToken(userTokenCredentials);
                Debug.WriteLine(result);
            } catch (Exception e) {
                Debug.Print("Exception when calling AuthenticationServiceApi.authenticateUserByToken: " + e.Message );
            }
        }
    }
    
    
    import com.pyramidanalytics
    from com.pyramidanalytics import ApiException
    from com.pyramidanalytics import AuthenticationServiceApi
    from pprint import pprint
    
        api_config = com.pyramidanalytics.Configuration(host = 'http://Your.Server.URL')
    
    with com.pyramidanalytics.ApiClient(api_config) as api_client:
        # Create an instance of the API class
        api_instance = AuthenticationServiceApi(api_client)
        # Initialize the userTokenCredentials parameter object for the call
        userTokenCredentials =  # UserTokenCredentials | 
    
        try:
            # Generates an access authentication token for a given user without their password, using an administrative token to authorize login to the application instead.
            api_response = api_instance.authenticate_user_by_token(userTokenCredentials)
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling AuthenticationServiceApi->authenticateUserByToken: %s\n" % e)
    <?php
    require_once(__DIR__ . '/vendor/autoload.php');
    
    OpenAPITools\Client\Configuration::getDefaultConfiguration()->setHost('http://Your.Server.URL');
    
    // Create an instance of the API class
    $api_instance = new OpenAPITools\Client\Api\AuthenticationServiceApi();
    $userTokenCredentials = ; // UserTokenCredentials | 
    
    try {
        $result = $api_instance->authenticateUserByToken($userTokenCredentials);
        print_r($result);
    } catch (Exception $e) {
        echo 'Exception when calling AuthenticationServiceApi->authenticateUserByToken: ', $e->getMessage(), PHP_EOL;
    }
    ?>